import Video, { IVideo } from './Video';
import Network from './Network';
import StreamInfo, { Info } from './StreamInfo';

type Role = 'customer' | 'agent';

type ClientStatus = 'idle' | 'permission' | 'publish' | 'published' | 'joining';

export interface IClient {
	clientId: string;
	customerRole: string;
	role: Role;
	userName: string;
	isRobot: boolean;
	status: ClientStatus;
	isTeamLeader: boolean;
}

export default class Client {
	public clientId: string;
	public customerRole: string;
	public role: Role;
	public userName: string;
	public isRobot: boolean;
	public status: ClientStatus;
	public network: Network;
	public isTeamLeader: boolean;
	public streamInfo: StreamInfo = new StreamInfo();
	public video: Video = new Video();

	constructor(client: IClient) {
		const { clientId, customerRole, role, userName, isRobot, status = 'idle', isTeamLeader = false } = client;
		this.role = role;
		this.isRobot = isRobot;
		this.clientId = clientId;
		this.customerRole = customerRole;
		this.userName = userName;
		this.status = status;
		this.isTeamLeader = isTeamLeader;
		this.network = new Network();
	}

	public setRobot() {
		this.isRobot = true;
	}

	public setStatus(status: ClientStatus) {
		this.status = status;
	}

	public setTeamLeader(isTeamLeader: boolean) {
		this.isTeamLeader = isTeamLeader;
	}

	public setStreamInfo(info: Info) {
		this.streamInfo.setStreamInfo(info);
	}

	public setVideoInfo(video: IVideo) {
		this.video.setVideoInfo(video);
	}

	public getStreamInfo() {
		return this.streamInfo;
	}

	public getVideoInfo() {
		return this.video;
	}
}
